﻿var functions = {
	GetMenu: function() {
		if(user == null){
    		return 'views/notConnected.html';
	    }else {
	        return 'views/connected.html';
	    }
	},
	GetJSON: function(obj) {
		return JSON.stringify(obj);
	},
	ParseJSON: function(obj) {
		return JSON.parse(obj);
	},
	GetItemInLocalStorage: function(name) {
		return localStorage.getItem(name);
	},
	SetItemInLocalStorage: function(name, obj) {
		localStorage.setItem(name, obj);
	},
	GetSignature: function(user, salt) {
		return this.Crypt(user.Id + user.Token + salt).toString(CryptoJS.enc.Base64);
	},
	GetError: function(mess) {
		alert(mess);
	},
	GetRequestParams: function(userId, sign, file) {
		return {
			'User': userId,
			'Sign': sign,
			'timestamp': new Date().getTime(),
			//'File': Crypto.util.base64ToBytes(file),
			'File': file,
			'Elt': file
		};
	},
	Crypt: function(value) {
		return CryptoJS.HmacSHA256(value, value);
	}
}

